var newVue = new Vue({
	el: "body",
	data: {
		btn: "获取验证码",
		userPhone: "",
		msg: "",
		code: "",
		newPwd: "",
		timeBreak: false
	},
	created: function() {
		init();
		_this = this;
	},
	methods: {
		checkPhone: function() {
			var phone = this.userPhone;
			var reg = /^1[34578]\d{9}$/;
			if(reg.test(phone)) {
				this.msg = true;
			} else {
				this.msg = false;
			}
		},
		getMsg: function() {
			if(this.msg) {
				this.timeBreak = true
				console.log(1)
				AV.User.requestPasswordResetBySmsCode(this.userPhone).then(function(success) {
					var n = 120
					var a = setInterval(function() {
						_this.btn = n-- + "秒后重试"
						if(n == 0) {
							_this.btn = "获取验证码"
							_this.timeBreak = false;
							clearInterval(a)
						}
					}, 1000)
				}, function(error) {
					alert("发送失败")
				});
			} else {
				alert("输入正确的手机号")
			}
		},
		register: function() {
			AV.User.resetPasswordBySmsCode(this.code,this.newPwd).then(function(success) {
				// 成功
				console.log(success)
				location.href = "../login/login.html"
			}, function(error) {
				// 失败
				console.log(error)
			});
		}

	}
})